package video.web;

import net.sf.json.JSONObject;
import util.GetHtml;
/**
 * url example http://v.ku6.com/show/0tKirMYJyve3_bPM89G57Q...html
 * @author ladjzero
 *
 */
public class Ku6 extends SuperParser{
	
	private boolean hasJson = false;
	
	private String jUrl;
	private JSONObject jData;
	
	public Ku6(String videoUrl){
		super(videoUrl);
	}
	
	public boolean isReachable(){
		if( null == content )
			return false;
		return true;
	}
	
	public String getFileUrl(){
		if( !hasJson )
			getJson();
		return jData.getString("f");
	}
	
	public String getImage(){
		if( !hasJson )
			getJson();
		return jData.getString("bigpicpath");
	}
	
	public String getSwf(){
		return "http://player.ku6.com/refer/"+vid+"/v.swf";
	}
	
	private void getJson(){
		jUrl = "http://v.ku6.com/fetch.htm?t=getVideo4Player&vid="+vid;
		String receive = new GetHtml().get( jUrl );
		jData = JSONObject.fromObject( receive ).getJSONObject("data");
	}

}
